package com.resource.studentmanage.controller;

import java.util.Arrays;
import java.util.Map;

import com.resource.common.utils.PageUtils;
import com.resource.common.utils.R;
import com.resource.studentmanage.entity.TStudentExamEntity;
import com.resource.studentmanage.feign.StudentExamRemote;
import com.resource.studentmanage.service.TStudentExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 学生考试统计表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2023-04-06 15:51:24
 */
@RestController
@RequestMapping("student/tstudentexam")
public class TStudentExamController implements StudentExamRemote {
    @Autowired
    private TStudentExamService tStudentExamService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tStudentExamService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id){
		TStudentExamEntity tStudentExam = tStudentExamService.getById(id);
        return R.ok().put("tStudentExam", tStudentExam);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody TStudentExamEntity tStudentExam){
		tStudentExamService.save(tStudentExam);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody TStudentExamEntity tStudentExam){
		tStudentExamService.updateById(tStudentExam);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
		tStudentExamService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }


    //生成学生考试记录
    @RequestMapping(value="/submitExam",method = RequestMethod.POST)
    public void dealStudentRecord(@RequestParam Map<String, String> map){
        tStudentExamService.submitEaxm(map);
    }

    @Override
    @RequestMapping(value="/feedback",method = RequestMethod.POST)
    public void submitMessageByExam(@RequestParam  Map<String, String> map) {
        tStudentExamService.submitMessageByExam(map);
    };

}
